import { createRouter, createWebHistory } from 'vue-router'

const routes = [
  {
    path: '/',
    redirect: '/dashboard'
  },
  {
    path: '/',
    component: () => import('../layout/index.vue'),
    children: [
      {
        path: 'dashboard',
        name: 'Dashboard',
        component: () => import('../views/Dashboard.vue'),
        meta: { title: '仪表盘', icon: 'Menu' }
      },
      {
        path: 'profile',
        name: 'Profile',
        component: () => import('../views/Profile.vue'),
        meta: { title: '个人信息', icon: 'User' }
      },
      {
        path: 'system',
        name: 'System',
        redirect: '/system/user',
        meta: { title: '系统管理', icon: 'Setting' },
        children: [
          {
            path: 'user',
            name: 'User',
            component: () => import('../views/system/User.vue'),
            meta: { title: '用户管理' }
          },
          {
            path: 'role',
            name: 'Role',
            component: () => import('../views/system/Role.vue'),
            meta: { title: '角色管理' }
          }
        ]
      },
      {
        path: 'data',
        name: 'Data',
        redirect: '/data/analysis',
        meta: { title: '数据中心', icon: 'DataLine' },
        children: [
          {
            path: 'analysis',
            name: 'Analysis',
            component: () => import('../views/data/Analysis.vue'),
            meta: { title: '数据分析' }
          },
          {
            path: 'statistics',
            name: 'Statistics',
            component: () => import('../views/data/Statistics.vue'),
            meta: { title: '统计报表' }
          }
        ]
      }
    ]
  },
  {
    path: '/login',
    name: 'Login',
    component: () => import('../views/Login.vue')
  }
]

const router = createRouter({
  history: createWebHistory(),
  routes
})

export default router 